package com.feedback;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.view.LayoutInflater;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.feedback.b.a;
import com.feedback.c.a;
import com.feedback.c.b;
import com.feedback.ui.FeedbackConversations;
import com.mobclick.android.UmengConstants;
import com.mobclick.android.t;

public class UMFeedbackService
{
  private static NotificationType a;
  private static Context b;
  private static boolean c = false;

  private static void b(String paramString)
  {
    NotificationManager localNotificationManager;
    Notification localNotification;
    PendingIntent localPendingIntent;
    PackageManager localPackageManager;
    Object localObject;
    if (a == NotificationType.NotificationBar)
    {
      localNotificationManager = (NotificationManager)b.getSystemService("notification");
      localNotification = new Notification(t.a(b, "drawable", "umeng_analyse_feedback_statusbar_icon"), b.getString(t.a(b, "string", "UMNewReplyFlick")), System.currentTimeMillis());
      Intent localIntent = new Intent(b, FeedbackConversations.class);
      localIntent.setFlags(131072);
      localPendingIntent = PendingIntent.getActivity(b, 0, localIntent, 0);
      localPackageManager = b.getPackageManager();
    }
    try
    {
      CharSequence localCharSequence = localPackageManager.getApplicationLabel(localPackageManager.getApplicationInfo(b.getPackageName(), 128));
      localObject = localCharSequence;
      if (localObject != null)
        localObject = localObject + " : ";
      localNotification.setLatestEventInfo(b, localObject + b.getString(t.a(b, "string", "UMNewReplyTitle")), b.getString(t.a(b, "string", "UMNewReplyHint")), localPendingIntent);
      localNotification.flags = 16;
      localNotificationManager.notify(0, localNotification);
      return;
    }
    catch (PackageManager.NameNotFoundException localNameNotFoundException)
    {
      while (true)
      {
        if (UmengConstants.testMode)
          localNameNotFoundException.printStackTrace();
        localObject = null;
      }
      LinearLayout localLinearLayout = (LinearLayout)LayoutInflater.from(b).inflate(t.a(b, "layout", "umeng_analyse_new_reply_alert_dialog"), null);
      TextView localTextView1 = (TextView)localLinearLayout.findViewById(t.a(b, "id", "umeng_analyse_new_reply_alert_title"));
      TextView localTextView2 = (TextView)localLinearLayout.findViewById(t.a(b, "id", "umeng_analyse_new_dev_reply_box"));
      localTextView2.setText(paramString);
      AlertDialog localAlertDialog = new AlertDialog.Builder(b).create();
      localAlertDialog.show();
      localAlertDialog.setContentView(localLinearLayout);
      localTextView1.setText(b.getString(t.a(b, "string", "UMNewReplyAlertTitle")));
      ((Button)localLinearLayout.findViewById(t.a(b, "id", "umeng_analyse_exitBtn"))).setOnClickListener(new a(localAlertDialog));
      Button localButton = (Button)localLinearLayout.findViewById(t.a(b, "id", "umeng_analyse_see_detail_btn"));
      b localb = new b(localAlertDialog);
      localButton.setOnClickListener(localb);
      localTextView2.setOnClickListener(localb);
    }
  }

  public static void enableNewReplyNotification(Context paramContext, NotificationType paramNotificationType)
  {
    c localc = new c();
    b = paramContext;
    a = paramNotificationType;
    new com.feedback.c.b(paramContext, localc).start();
    new com.feedback.c.a(paramContext).start();
    c = true;
  }

  public static boolean getHasCheckedReply()
  {
    return c;
  }

  public static void openUmengFeedbackSDK(Context paramContext)
  {
    com.feedback.b.a.a(paramContext);
  }
}